import Emberbox from "@/utils/mapbox/engine";
import { baseurl } from "../../config";

export default function buildingsManage(emberbox: Emberbox) {
  let data: any = null,
    mapBoundary: any = null,
    isShow: boolean = true;
  fetch(`${baseurl}/mapBoundary`)
    .then((res) => res.json())
    .then((res: any) => {
      data = res;
      console.log("mapBoundary", res);

      mapBoundary = emberbox.geojsonManage?.addJson(res, false);
      isShow = true;
      console.log("buildings", mapBoundary);
    })
    .catch((err) => {
      console.log("数据获取失败：mapBoundary");
    });

  //   emberbox.on("onZoom", (e: number) => {
  //     if (data === null) return;
  //     if (e > 18.3 && isShow) {
  //       isShow = false;
  //       emberbox.geojsonManage?.removeJson(buildings);
  //       buildings = null;
  //     }

  //     if (e < 18 && isShow === false) {
  //       isShow = true;
  //       buildings = emberbox.geojsonManage?.addIndoorJson(data);
  //     }
  //   });
}
